package com.dap.controller;

import com.dap.service.ApplicationService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/Application")
public class ApplicationController {

    @Autowired
    private ApplicationService applicationService;

    @RequestMapping(value = "/getApplicationList",method = RequestMethod.GET)
    public String getFlowControlRate() throws JsonProcessingException {
        //调试代码
        System.out.println("我被访问了");

        ObjectMapper objectMapper = new ObjectMapper();
        List<String> applicationList = applicationService.getApplicationList();
        String s = objectMapper.writeValueAsString(applicationList);
        return s;
    }


    @RequestMapping(value = "/getInterfaceList",method = RequestMethod.GET)
    public String getInterfaceList(String applicationName) throws JsonProcessingException {

        ObjectMapper objectMapper = new ObjectMapper();
        List<String> interfaceNameList = applicationService.getInterfaceNameList(applicationName);
        String s = objectMapper.writeValueAsString(interfaceNameList);
        return s;
    }


    @RequestMapping(value = "/getGroupList",method = RequestMethod.GET)
    public String getGroupList(String applicationName,String interfaceName) throws JsonProcessingException {

        ObjectMapper objectMapper = new ObjectMapper();
        List<String> groupList = applicationService.getGroupList(applicationName, interfaceName);
        String s = objectMapper.writeValueAsString(groupList);
        return s;
    }







}
